package top.drinyeit.weilong.fragment;

import android.annotation.SuppressLint;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.scu.miomin.shswiperefresh.core.SHSwipeRefreshLayout;

import top.drinyeit.weilong.R;
import top.drinyeit.weilong.databinding.OrderView;
import top.drinyeit.weilong.viewmodel.OrderVM;

/**
 * Created by YJY on 2018/1/12.
 */

@SuppressLint("ValidFragment")
public class OrderFragment extends LazyFragment2 {

    OrderView mOrderView;
    private int type;
    public SHSwipeRefreshLayout shSwipeRefreshLayout;
    public RecyclerView orderList;

    public OrderFragment(int type) {
        this.type = type;
    }

    @Override
    protected View initDatabindingAndView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mOrderView = DataBindingUtil.inflate(inflater, R.layout.fragment_order, container, false);
        initList();
        return mOrderView.getRoot();
    }

    @Override
    protected void lazyLoad() {
        mOrderView.setIOrderView(new OrderVM(this, type));
    }

    private void initList() {
        shSwipeRefreshLayout = (SHSwipeRefreshLayout) mOrderView.getRoot().findViewById(R.id.srl_order);
        shSwipeRefreshLayout.setOnRefreshListener(new SHSwipeRefreshLayout.SHSOnRefreshListener() {
            @Override
            public void onRefresh() {

            }

            @Override
            public void onLoading() {

            }

            @Override
            public void onRefreshPulStateChange(float v, int i) {

            }

            @Override
            public void onLoadmorePullStateChange(float v, int i) {

            }
        });
        orderList = (RecyclerView) mOrderView.getRoot().findViewById(R.id.list_order);
        orderList.setLayoutManager(new LinearLayoutManager(getActivity()));
        orderList.setHasFixedSize(true);
    }
}
